﻿package mortal.game.view.levelReward
{
    import flash.events.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.signUp.data.*;
    import mortal.game.view.signUp.util.*;
    import mortal.mvc.core.*;

    public class WelfareIcon extends ActionBaseIcon
    {
        private var _txtNum:BitmapNumberText;
        private static var _instance:WelfareIcon;

        public function WelfareIcon()
        {
            super(ResFileConst.WelfareIcon);
            this.name = "WelfareIcon";
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.name = "LevelRewardIcon";
            this._txtNum = UIFactory.bitmapNumberText(45, 0, "FightInfoNum.png", 12, 15, -1, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.name = "";
            this._txtNum.dispose(param1);
            this._txtNum = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            if (GameController.signUp.view.isHide)
            {
                _loc_2 = Cache.instance.role.entityInfo.level;
                _loc_3 = 0;
                while (_loc_3 < SignUpConst.Tag_TotalNum)
                {
                    
                    _loc_4 = SignUpTabType.getOpenLevel(SignUpTabType.tabArr[_loc_3]);
                    if (_loc_2 >= _loc_4)
                    {
                        _loc_5 = SignUpTabType.tabIndexObj[SignUpTabType.tabArr[_loc_3]] as int;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.SignUpOpenWinAndSwitchTag, _loc_5));
                        break;
                    }
                    _loc_3++;
                }
            }
            else
            {
                GameController.signUp.view.hide();
            }
            return;
        }// end function

        override public function hide() : void
        {
            super.hide();
            return;
        }// end function

        public function get numText() : BitmapNumberText
        {
            return this._txtNum;
        }// end function

        public static function get instance() : WelfareIcon
        {
            if (!_instance)
            {
                _instance = new WelfareIcon;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
